home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3315 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.7 KB

  1. Path: ix.netcom.com!netnews
  2. From: miker3@ix.netcom.com (Mike Rubenstein)
  3. Newsgroups: comp.lang.ada,comp.lang.c++,comp.lang.c,comp.lang.modula3,comp.lang.modula2,comp.lang.eiffel
  4. Subject: Re: Hungarian notation
  5. Date: Tue, 23 Jan 1996 11:03:03 GMT
  6. Organization: Netcom
  7. Message-ID: <3104bfc8.132251392@nntp.ix.netcom.com>
  8. References: <30C40F77.53B5@swsbbs.com> <4d2ok0$69s@beach.and.nl> <4dtv3gINNo9u@keats.ugrad.cs.ubc.ca> <SPENCER.96Jan22113215@zorgon.ERA.COM> <4e1nd8$hv0@solutions.solon.com>
  9. NNTP-Posting-Host: ix-dc6-08.ix.netcom.com
  10. X-NETCOM-Date: Tue Jan 23  3:02:33 AM PST 1996
  11. X-Newsreader: Forte Agent .99c/16.141
  12.  
  13. seebs@solutions.solon.com (Peter Seebach) wrote:
  14.  
  15. > In article <SPENCER.96Jan22113215@zorgon.ERA.COM>,
  16. > Spencer Allain <spencer@ERA.COM> wrote:
  17. > >It is incorrect to say that a 'char' (of size 1 byte on many systems)
  18. > >and an 'int' (of size 4 bytes on many systems) is structurally
  19. > >equivalent, yet I must be able to compile this without errors:
  20. > >(warnings are _not_ errors -- though I get none compiling this anyway)
  21. > >   char a;
  22. > >   int b;
  23. >  
  24. > >   int main()
  25. > >   {
  26. > >     b = -154267 ;
  27. > >     a = b ;
  28. > >     return 0 ;
  29. > >   }
  30. > No warnings, perhaps, but undefined behavior unless CHAR_MIN is
  31. > less than or equal to -154267.
  32. > And yes, we know C intentionally gives up some type safety for being
  33. > easy to compile.
  34. > :)
  35.  
  36. That does not result in undefined behavior.  From ISO 6.2.1.2:
  37.  
  38.     When a value with integral type is demoted to a signed integer
  39.  
  40.     with smaller size or an unsigned integer is converted to its 
  41.     corresponding signed integer, if the value cannot be 
  42.     represented the result is implementation defined.
  43.  
  44. An implementation must handle this and must document how it does so.
  45.  
  46.  
  47. Michael M Rubenstein
  48.